<template>
	<view>
		<TopNavCustom :title="title"></TopNavCustom>
		<view class="container">
			<text>{{time}}</text>
			<view class="add-zone">
				<view class="add-form">
					<u-cell-group :border="false">
						<u-cell v-if="progressData.estateLocation != ''" size="normal" title="目标位置"
							:value="progressData.estateLocation">
						</u-cell>
						<u-cell size="normal" title="开工时间" :value="progressData.startTime">
						</u-cell>
						<u-cell size="normal" title="结工时间" :value="progressData.endTime">
						</u-cell>
						<u-cell size="normal" title="反馈描述" :border="false"></u-cell>
						<view class="pixs">
							<textarea :value="progressData.feedBack" placeholder="请描述问题，最多输入200个字" disabled />
						</view>
						<u-cell size="normal" title="现场情况" :border="false"></u-cell>
						<view class="pixs">
							<view v-for="(img,i) in progressData.pixs">
								<image :src="getSrc(img)" class="pix"></image>
							</view>
						</view>
					</u-cell-group>
				</view>
			</view>
			<view class="btns" v-if="progressData.eventStatus === 3">
				<button type="default" class="next" @click="()=>showModal = true">删除</button>
			</view>
			<view class="btns" v-if="progressData.eventStatus === 4">
				<button type="default" class="next" @click="goto()">重新编辑</button>
			</view>
			<u-modal :show="showModal" title="删除记录" :content='content' @confirm="confirm" :showCancelButton='true'
				@cancel="()=>showModal=false">
			</u-modal>
		</view>
	</view>

</template>

<script>
	import $C from '@/common/config.js'
	import _project from "@/common/project.js"
	export default {
		data() {
			return {
				progressData: {},
				loading: false,
				pickerDateTitle: '',
				showDateTime: false,
				dateTime: Number(new Date()),
				time: uni.$u.timeFormat(false, 'yyyy-mm-dd'),
				fileIds: [],
				flag: 0,
				formList: [],
				fileList: [],
				columns: [],
				pickerTitle: '',
				showEmpty: true,
				title: "接受上级传参",
				show: false,
				temp: {},
				showModal: false,
				_para: '',
				content: "是否删除该条记录？"
			};
		},
		methods: {
			getSrc(id) {
				if ((typeof id) != undefined && id != '') {
					let _src = $C.baseUrl + '/file/download?fileId=' + id
					return _src
				}
			},
			async confirm() {
				let result = await _project.deleteEvent(this.progressData.eventId)
				if (result) {
					this.showModal = false
					uni.$showMsg('删除成功！')
					uni.$u.sleep(500).then(() => {
						uni.navigateBack({
							delta: 1
						})
					})
				}
			},
			onLoad(params) {
				this._para = params.item
				let temp = JSON.parse(decodeURIComponent(params.item))
				this.title = temp.title
				this.progressData = temp
				this.progressData.pixs = temp.imgs.split(',')
				if (this.progressData.type == 1) {
					this.progressData.estateLocation = ''

				}
				console.log(temp)
			},
			goto() {
				if (this.progressData.type == 1) {
					uni.navigateTo({
						url: '/pages/idata/note/upload_note/upload_note?item=' + this._para
					})
				} else {
					uni.navigateTo({
						url: '/pages/idata/note/upload_house_node/upload_house_node?item=' + this._para
					})
				}

			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 30rpx 30rpx 60rpx 30rpx;
	}

	.add-zone {
		padding: 20rpx;
		border: 1rpx solid #efefef;
		border-radius: 20rpx;
		background-color: #FFFFFF;
	}

	.add-form {
		display: flex;
		flex-direction: column;

		.pixs {
			padding: 20rpx;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			justify-content: space-around;

			.pix {
				display: block;
				width: 140rpx;
				height: 140rpx;
			}
		}
	}

	.click-zone {
		display: flex;
		flex-direction: row;
		justify-content: space-between;

		.pix {
			width: 40rpx;
			height: 40rpx;
		}
	}

	.btns {
		margin-top: 88rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;

		.next {
			color: #FFFFFF;
			width: 560rpx;
			background: linear-gradient(90deg, #E62129 0%, #BA000A 100%);
			box-shadow: 0rpx 5rpx 15rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 44rpx;
		}
	}
</style>
